#pragma once

#include "GraphicD3D.h"
#include "DrawableD3D.h"
#include <hash_map>
#include "isingleton.h"
#include <utility>
namespace Graphics
{
	enum API_TYPE
	{
		API_UNDEF = 0,
		API_D3D9 ,
		API_OPENGL
	};
	class GraphicHolder: public ::ISingleton<GraphicHolder,std::pair<API_TYPE,Window> >
	{
	private:
		//Static buffer
		
		stdext::hash_map<string,Drawable*> m_Cache;
		Graphic2D* m_Graphic2D;
		API_TYPE m_API;

	public:
		GraphicHolder(std::pair<API_TYPE,Window> param);
		~GraphicHolder(void);

		API_TYPE& GetAPI(void);

		//// Initialize the graphic object by specific API
		//bool Init(API_TYPE api,Window& win);

		// Get the Graphic2D object
		Graphic2D* const GetGraphic2D(void);

		// Create or get a Drawable object from cache
		Drawable* GetDrawableFromCache(const std::string& filename,DWORD colorKey = 0);

		// Create or get a Drawable object from cache
		Drawable* CreateDrawable(int width, int height);
		Drawable* CreateDrawable(const std::string& filename,DWORD colorKey = 0);

	};
}